$(function() {
    $("#accumulateTable").bootstrapTable('destroy').bootstrapTable({
        url : window.portAddress + "/accumulate/accumulateList",
        dataType : "json",
        method : 'get',
        striped: true,  //行间隔色
        cache : false,  //禁用缓存
        pageNumber: 1,  //初始化加载第一页
        pagination: true,//是否分页
        sidePagination: "client",//前端分页
        pageSize: 5,//单页记录数
        pageList: [5, 10, 15],//可选择单页记录数
        clickToSelect : true,
        theadClasses: "thead-pink",
        queryParams: function (params) {
            //向服务器传递的参数
            return {
               /* option : $("#search_option option:selected").val(),*/
                tradeDate : $("#tradeDate").val(),
                currency : $("#currency").val(),
                accumulatedNo : $("#accumulatedNo").val(),
            };
        },
        responseHandler : function(res) {
            return res.data;
        },
        columns : [
            {
                title : "交易日期",
                field : "tradeDate",
                align : "center",
            },
            {
                title : "货币",
                field : "currency",
                align : "center",
            },
            {
                title : "金额",
                field : "amount",
                align : "center",
            },
            {
                title : "等值港币",
                field : "hkdEquAmt",
                align : "center",
            },
            {
                title : "累总编号",
                field : "accumulatedNo",
                align : "center",
            },
            {
                title : "状态",
                field : "status",
                align : "center",
            }
        ]
    });

    $("#search").click(function() {
        $.ajax({
            url : window.portAddress + "/accumulate/accumulateList",
            type : "post",
            data : {
                tradeDate : $("#tradeDate").val(),
                currency : $("#currency").val(),
                accumulatedNo : $("#accumulatedNo").val(),
            },
            dataType : "json",
            success : function(data) {
                if (data.state === '000000') {
                    toastr.success("查询数据成功");
                }else {
                    toastr.error(data.message);
                }
                $("#accumulateTable").bootstrapTable("refresh");
            }
        })

    });

    $("#export").click(function() {

        var baseUrl = window.portAddress + "/accumulate/export?";
        var tradeDate = $("#tradeDate").val();
        var currency = $("#currency option:selected").val();
        var accumulatedNo = $("#accumulatedNo").val();

        window.location= baseUrl + "tradeDate=" + tradeDate + "&"
            + "currency=" + currency + "&" + "accumulatedNo=" + accumulatedNo

    });


})
